import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

import Login from '@/star_wish/Login'
import Home from '@/star_wish/Home'
import Manager from "@/star_wish/system/Manager";
import Permission from "@/star_wish/system/Permission";
import Role from "@/star_wish/system/Role";
import Article from "@/star_wish/article/Article";
import Advice from "@/star_wish/advice/Advice";
import Category from "@/star_wish/category/Category";
import Tag from "@/star_wish/tag/Tag";
import Board from "@/star_wish/board/Board";
import User from "@/star_wish/user/User";
import History from "@/star_wish/user/History";
import Follow from "@/star_wish/user/Follow";
import Comment from "@/star_wish/comment/Comment";
import Image from "@/star_wish/image/Image";
import UserLog from "@/star_wish/log/UserLog";
import OperationLog from "@/star_wish/log/OperationLog";
import ArticleCollection from "@/star_wish/article/ArticleCollection";
import ArticleLike from "@/star_wish/article/ArticleLike";
import WelCome from "@/star_wish/WelCome";
const routes = [
  {
    path: "/",
    name: "Login",
    component: Login
  },
  {
    path: "/Login",
    name: "Login",
    component: Login
  },
  {
    path:"/Home",
    name:"Home",
    component:Home,
    children:[
      {path:"/",name:"WelCome",component:WelCome},
      {
        path: "/ManagerList",
        name: "Manager",
        component: Manager
      },
      {
        path: "/PermissionList",
        name: "Permission",
        component: Permission
      },
      {
        path: "/RoleList",
        name: "Role",
        component: Role
      },
      {
        path: "/ArticleList",
        name: "Article",
        component: Article
      },
      {
        path: "/CollectionList",
        name: "ArticleCollection",
        component: ArticleCollection
      },
      {
        path: "/LikeList",
        name: "ArticleLike",
        component: ArticleLike
      },
      {
        path: "/AdviceList",
        name: "Advice",
        component: Advice
      },
      {
        path: "/CategoryList",
        name: "Category",
        component: Category
      },
      {
        path: "/TagList",
        name: "Tag",
        component: Tag
      },
      {
        path: "/BoardList",
        name: "Board",
        component: Board
      },
      {
        path: "/UserList",
        name: "User",
        component: User
      },
      {
        path: "/HistoryList",
        name: "History",
        component: History
      },
      {
        path: "/FollowList",
        name: "Follow",
        component: Follow
      },
      {
        path: "/CommentList",
        name: "Comment",
        component: Comment
      },
      {
        path: "/ImageList",
        name: "Image",
        component: Image
      },
      {
        path: "/UserLogList",
        name: "UserLog",
        component: UserLog
      },
      {
        path: "/OperationLogList",
        name: "OperationLog",
        component: OperationLog
      }
    ]
  }
]


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to,from,next)=>{
//   let toPath = to.path;
//   let fromPath = from.path;
//   console.log(toPath,fromPath);
//   if (toPath == '/' || toPath == "/Login"){
//     next() ;// 放行   chain.doFilter()
//   }else  {
//     // 如果你要是登录过了   你可以访问 ，如果你没有登录 你就回到登录页面
//     let admin = sessionStorage.getItem("adminInfo");
//     if(admin) {
//       //放行
//       next();
//     }else {
//       new Vue().$message.error('请先登录！')
//       next("/Login"); //回到登录界面
//     }
//   }
// })


export default router
